home *** CD-ROM | disk | FTP | other *** search
/ Columbia Kermit / kermit.zip / newsgroups / misc.20020314-20021006 / 000024_fdc@columbia.edu_Fri Apr 5 17:07:38 EST 2002.msg < prev    next >
Text File  |  2020-01-01  |  3KB  |  102 lines

  1. Article: 13295 of comp.protocols.kermit.misc
  2. Path: newsmaster.cc.columbia.edu!news.columbia.edu!news-not-for-mail
  3. From: fdc@columbia.edu (Frank da Cruz)
  4. Newsgroups: comp.protocols.kermit.misc
  5. Subject: Re: How to get return code from external Unix box running simple shell script?
  6. Date: 5 Apr 2002 17:07:26 -0500
  7. Organization: Columbia University
  8. Lines: 85
  9. Message-ID: <a8l76u$j5e$1@watsol.cc.columbia.edu>
  10. References: <d6e12cad.0204051329.574003a2@posting.google.com>
  11. NNTP-Posting-Host: watsol.cc.columbia.edu
  12. X-Trace: newsmaster.cc.columbia.edu 1018044447 17555 128.59.39.139 (5 Apr 2002 22:07:27 GMT)
  13. X-Complaints-To: postmaster@columbia.edu
  14. NNTP-Posting-Date: 5 Apr 2002 22:07:27 GMT
  15. Xref: newsmaster.cc.columbia.edu comp.protocols.kermit.misc:13295
  16.  
  17. In article <d6e12cad.0204051329.574003a2@posting.google.com>,
  18. Entfred <entfred@hotmail.com> wrote:
  19. : I saw an old post that Frank da Cruz said about using IF SUCCESS or
  20. : IF FAILURE to test the success or failure reported by an external command.
  21. : What I want to do is something a little different:
  22. : 1. Kermit script (on a Windows 2000 PC) telnets to an external Sun
  23. : Unix box.  The Kermit script is in a file called test.ksc:
  24. : set term type at386
  25. : set network tcp/ip
  26. : set host test.machine.com
  27. : output \13
  28. : input 5 login:
  29. : output testuser\13
  30. : input 5 password:
  31. : output testpassword\13
  32. : input 5 $
  33. : output testscript\13
  34. : connect
  35. : if fail (I am not sure what do do right here to get Unix return code)
  36. : Exit
  37. : End ;
  38. : 2. On the Unix box, a simple script is run:
  39. : (call the script, testscript)
  40. : echo This is a test 
  41. : date
  42. : exit 9
  43. : 3. I would like the result code of 9 to be sent back to the kermit 
  44. : script residing on the Windows 2000 PC.  
  45. : How would this be done?  Any tips to doing this would be
  46. : appreciated!
  47. You would use Kermit's client/server features, something like this:
  48.  
  49.   ; Part 1: Make connection, authenticate, start Kermit server
  50.  
  51.   set network tcp/ip
  52.   set host test.machine.com
  53.   if fail exit 1 Can't reach host
  54.   set exit warning off
  55.   lineout
  56.   input 5 login:
  57.   if fail exit 1 No login prompt
  58.   lineout testuser
  59.   input 5 password:
  60.   if fail exit 1 No password prompt
  61.   lineout testpassword
  62.   input 5 $
  63.   if fail exit 1 No shell prompt
  64.   lineout kermit -x
  65.   input 5 KERMIT READY TO SERVE...
  66.   if fail echo WARNING: missing server message - continuing...
  67.  
  68.   ; Part 2: The real work
  69.  
  70.   remote host testscript
  71.   query kermit pexitstat
  72.   echo testscript return code = \v(query)
  73.   bye
  74.   End ;
  75.  
  76. Notes:
  77.  
  78.  1. Always remember to test critical commands for failure.
  79.  
  80.  2. "lineout blah" is equivalent to "output blah\13", but better,
  81.     since it adjusts the line terminator according to the connection type.
  82.  
  83.  3. \v(pexitstat) is the Kermit built-in variable that contains the exit
  84.     status code of the most recently invoked inferior process.
  85.  
  86.  4. Part 1 is a lot easier and less reliant on changeable prompts 
  87.     and strings if a Kermit server is already there waiting for you, 
  88.     as would be the case with an Internet Kermit Service:
  89.  
  90.       http://www.columbia.edu/kermit/cuiksd.html
  91.  
  92. - Frank
  93.